import sqlite3

conn = sqlite3.connect('testdb')

cursor = conn.cursor()
# cursor.execute("drop TABLE testdb")
# cursor.execute('''
# CREATE TABLE testdb (
#   id  int PRIMARY KEY ,
#   name text,
#   intro text
# )
# ''')

sql = 'insert into testdb (id,name, intro) VALUES (?,?,?)'
f = open('data.csv')
for line in f:
    line = line.rstrip()
    cols = line.split(',')
    if (len(cols) <=1):
        continue
    cursor.execute(sql, [int(cols[0]),cols[1],cols[2]])
conn.commit() # without this line, data will not be stored.
f.close()
cursor.close()

conn.close()
